<!DOCTYPE HTML>

<html lang="en">
<head>

<title>SecurityMockMvcRequestPostProcessors (spring-security-docs 5.6.3 API)</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../../../../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../../../jquery/jquery-ui.css" title="Style">
<script type="text/javascript" src="../../../../../../../script.js"></script>
<script type="text/javascript" src="../../../../../../../jquery/jszip/dist/jszip.min.js"></script>
<script type="text/javascript" src="../../../../../../../jquery/jszip-utils/dist/jszip-utils.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src="../../../../../../../jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script>
<![endif]-->
<script type="text/javascript" src="../../../../../../../jquery/jquery-3.5.1.js"></script>
<script type="text/javascript" src="../../../../../../../jquery/jquery-ui.js"></script>
</head>
<body>
<script type="text/javascript"><!--
    try {
        if (location.href.indexOf('is-external=true') == -1) {
            parent.document.title="SecurityMockMvcRequestPostProcessors (spring-security-docs 5.6.3 API)";
        }
    }
    catch(err) {
    }
//-->
var data = {"i0":9,"i1":9,"i2":9,"i3":9,"i4":9,"i5":9,"i6":9,"i7":9,"i8":9,"i9":9,"i10":9,"i11":9,"i12":9,"i13":9,"i14":9,"i15":9,"i16":9,"i17":9};
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
var pathtoroot = "../../../../../../../";
var useModuleDirectories = true;
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<header role="banner">
<nav role="navigation">
<div class="fixedNav">

<div class="topNav"><a id="navbar.top">

</a>
<div class="skipNav"><a href="SecurityMockMvcRequestPostProcessors.html#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.top.firstrow">

</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../../index.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../../../allclasses.html">All&nbsp;Classes</a></li>
</ul>
<ul class="navListSearch">
<li><label for="search">SEARCH:</label>
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">
</li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_top");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li><a href="SecurityMockMvcRequestPostProcessors.html#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="SecurityMockMvcRequestPostProcessors.html#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="SecurityMockMvcRequestPostProcessors.html#method.detail">Method</a></li>
</ul>
</div>
<a id="skip.navbar.top">

</a></div>

</div>
<div class="navPadding">&nbsp;</div>
<script type="text/javascript"><!--
$('.navPadding').css('padding-top', $('.fixedNav').css("height"));
//-->
</script>
</nav>
</header>

<main role="main">
<div class="header">
<div class="subTitle"><span class="packageLabelInType">Package</span>&nbsp;<a href="package-summary.html">org.springframework.security.test.web.servlet.request</a></div>
<h2 title="Class SecurityMockMvcRequestPostProcessors" class="title">Class SecurityMockMvcRequestPostProcessors</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<pre>public final class <span class="typeNameLabel">SecurityMockMvcRequestPostProcessors</span>
extends java.lang.Object</pre>
<div class="block">Contains <code>MockMvc</code> <code>RequestPostProcessor</code> implementations for Spring
Security.</div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>4.0</dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">

<section role="region">
<ul class="blockList">
<li class="blockList"><a id="nested.class.summary">

</a>
<h3>Nested Class Summary</h3>
<table class="memberSummary">
<caption><span>Nested Classes</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Class</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static class&nbsp;</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.CsrfRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.CsrfRequestPostProcessor</a></span></code></th>
<td class="colLast">
<div class="block">Populates a valid <a href="../../../../web/csrf/CsrfToken.html" title="interface in org.springframework.security.web.csrf"><code>CsrfToken</code></a> into the request.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static class&nbsp;</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.DigestRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.DigestRequestPostProcessor</a></span></code></th>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static class&nbsp;</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessor</a></span></code></th>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static class&nbsp;</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.OAuth2ClientRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.OAuth2ClientRequestPostProcessor</a></span></code></th>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static class&nbsp;</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.OAuth2LoginRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.OAuth2LoginRequestPostProcessor</a></span></code></th>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static class&nbsp;</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.OidcLoginRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.OidcLoginRequestPostProcessor</a></span></code></th>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static class&nbsp;</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.OpaqueTokenRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.OpaqueTokenRequestPostProcessor</a></span></code></th>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static class&nbsp;</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor</a></span></code></th>
<td class="colLast">
<div class="block">Creates a <a href="../../../../authentication/UsernamePasswordAuthenticationToken.html" title="class in org.springframework.security.authentication"><code>UsernamePasswordAuthenticationToken</code></a> and sets the principal to be
a <a href="../../../../core/userdetails/User.html" title="class in org.springframework.security.core.userdetails"><code>User</code></a> and associates it to the <code>MockHttpServletRequest</code>.</div>
</td>
</tr>
</table>
</li>
</ul>
</section>

<section role="region">
<ul class="blockList">
<li class="blockList"><a id="method.summary">

</a>
<h3>Method Summary</h3>
<table class="memberSummary">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Method</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>static org.springframework.test.web.servlet.request.RequestPostProcessor</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.html#anonymous()">anonymous</a></span>()</code></th>
<td class="colLast">
<div class="block">Establish a <a href="../../../../core/context/SecurityContext.html" title="interface in org.springframework.security.core.context"><code>SecurityContext</code></a> that uses an
<a href="../../../../authentication/AnonymousAuthenticationToken.html" title="class in org.springframework.security.authentication"><code>AnonymousAuthenticationToken</code></a>.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>static org.springframework.test.web.servlet.request.RequestPostProcessor</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.html#authentication(org.springframework.security.core.Authentication)">authentication</a></span>&#8203;(<a href="../../../../core/Authentication.html" title="interface in org.springframework.security.core">Authentication</a>&nbsp;authentication)</code></th>
<td class="colLast">
<div class="block">Establish a <a href="../../../../core/context/SecurityContext.html" title="interface in org.springframework.security.core.context"><code>SecurityContext</code></a> that uses the specified <a href="../../../../core/Authentication.html" title="interface in org.springframework.security.core"><code>Authentication</code></a>
for the <a href="../../../../core/Authentication.html#getPrincipal()"><code>Authentication.getPrincipal()</code></a> and a custom <a href="../../../../core/userdetails/UserDetails.html" title="interface in org.springframework.security.core.userdetails"><code>UserDetails</code></a>.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>static <a href="SecurityMockMvcRequestPostProcessors.CsrfRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.CsrfRequestPostProcessor</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.html#csrf()">csrf</a></span>()</code></th>
<td class="colLast">
<div class="block">Creates a <code>RequestPostProcessor</code> that will automatically populate a valid
<a href="../../../../web/csrf/CsrfToken.html" title="interface in org.springframework.security.web.csrf"><code>CsrfToken</code></a> in the request.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>static <a href="SecurityMockMvcRequestPostProcessors.DigestRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.DigestRequestPostProcessor</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.html#digest()">digest</a></span>()</code></th>
<td class="colLast">
<div class="block">Creates a DigestRequestPostProcessor that enables easily adding digest based
authentication to a request.</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>static <a href="SecurityMockMvcRequestPostProcessors.DigestRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.DigestRequestPostProcessor</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.html#digest(java.lang.String)">digest</a></span>&#8203;(java.lang.String&nbsp;username)</code></th>
<td class="colLast">
<div class="block">Creates a DigestRequestPostProcessor that enables easily adding digest based
authentication to a request.</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code>static org.springframework.test.web.servlet.request.RequestPostProcessor</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.html#httpBasic(java.lang.String,java.lang.String)">httpBasic</a></span>&#8203;(java.lang.String&nbsp;username,
java.lang.String&nbsp;password)</code></th>
<td class="colLast">
<div class="block">Convenience mechanism for setting the Authorization header to use HTTP Basic with
the given username and password.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>static <a href="SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessor</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.html#jwt()">jwt</a></span>()</code></th>
<td class="colLast">
<div class="block">Establish a <a href="../../../../core/context/SecurityContext.html" title="interface in org.springframework.security.core.context"><code>SecurityContext</code></a> that has a <a href="../../../../oauth2/server/resource/authentication/JwtAuthenticationToken.html" title="class in org.springframework.security.oauth2.server.resource.authentication"><code>JwtAuthenticationToken</code></a> for
the <a href="../../../../core/Authentication.html" title="interface in org.springframework.security.core"><code>Authentication</code></a> and a <a href="../../../../oauth2/jwt/Jwt.html" title="class in org.springframework.security.oauth2.jwt"><code>Jwt</code></a> for the
<a href="../../../../core/Authentication.html#getPrincipal()"><code>Authentication.getPrincipal()</code></a>.</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code>static <a href="SecurityMockMvcRequestPostProcessors.OAuth2ClientRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.OAuth2ClientRequestPostProcessor</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.html#oauth2Client()">oauth2Client</a></span>()</code></th>
<td class="colLast">
<div class="block">Establish an <a href="../../../../oauth2/client/OAuth2AuthorizedClient.html" title="class in org.springframework.security.oauth2.client"><code>OAuth2AuthorizedClient</code></a> in the session.</div>
</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code>static <a href="SecurityMockMvcRequestPostProcessors.OAuth2ClientRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.OAuth2ClientRequestPostProcessor</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.html#oauth2Client(java.lang.String)">oauth2Client</a></span>&#8203;(java.lang.String&nbsp;registrationId)</code></th>
<td class="colLast">
<div class="block">Establish an <a href="../../../../oauth2/client/OAuth2AuthorizedClient.html" title="class in org.springframework.security.oauth2.client"><code>OAuth2AuthorizedClient</code></a> in the session.</div>
</td>
</tr>
<tr id="i9" class="rowColor">
<td class="colFirst"><code>static <a href="SecurityMockMvcRequestPostProcessors.OAuth2LoginRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.OAuth2LoginRequestPostProcessor</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.html#oauth2Login()">oauth2Login</a></span>()</code></th>
<td class="colLast">
<div class="block">Establish a <a href="../../../../core/context/SecurityContext.html" title="interface in org.springframework.security.core.context"><code>SecurityContext</code></a> that has a <a href="../../../../oauth2/client/authentication/OAuth2AuthenticationToken.html" title="class in org.springframework.security.oauth2.client.authentication"><code>OAuth2AuthenticationToken</code></a>
for the <a href="../../../../core/Authentication.html" title="interface in org.springframework.security.core"><code>Authentication</code></a>, a <a href="../../../../oauth2/core/user/OAuth2User.html" title="interface in org.springframework.security.oauth2.core.user"><code>OAuth2User</code></a> as the principal, and a
<a href="../../../../oauth2/client/OAuth2AuthorizedClient.html" title="class in org.springframework.security.oauth2.client"><code>OAuth2AuthorizedClient</code></a> in the session.</div>
</td>
</tr>
<tr id="i10" class="altColor">
<td class="colFirst"><code>static <a href="SecurityMockMvcRequestPostProcessors.OidcLoginRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.OidcLoginRequestPostProcessor</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.html#oidcLogin()">oidcLogin</a></span>()</code></th>
<td class="colLast">
<div class="block">Establish a <a href="../../../../core/context/SecurityContext.html" title="interface in org.springframework.security.core.context"><code>SecurityContext</code></a> that has a <a href="../../../../oauth2/client/authentication/OAuth2AuthenticationToken.html" title="class in org.springframework.security.oauth2.client.authentication"><code>OAuth2AuthenticationToken</code></a>
for the <a href="../../../../core/Authentication.html" title="interface in org.springframework.security.core"><code>Authentication</code></a>, a <a href="../../../../oauth2/core/oidc/user/OidcUser.html" title="interface in org.springframework.security.oauth2.core.oidc.user"><code>OidcUser</code></a> as the principal, and a
<a href="../../../../oauth2/client/OAuth2AuthorizedClient.html" title="class in org.springframework.security.oauth2.client"><code>OAuth2AuthorizedClient</code></a> in the session.</div>
</td>
</tr>
<tr id="i11" class="rowColor">
<td class="colFirst"><code>static <a href="SecurityMockMvcRequestPostProcessors.OpaqueTokenRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.OpaqueTokenRequestPostProcessor</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.html#opaqueToken()">opaqueToken</a></span>()</code></th>
<td class="colLast">
<div class="block">Establish a <a href="../../../../core/context/SecurityContext.html" title="interface in org.springframework.security.core.context"><code>SecurityContext</code></a> that has a <a href="../../../../oauth2/server/resource/authentication/BearerTokenAuthentication.html" title="class in org.springframework.security.oauth2.server.resource.authentication"><code>BearerTokenAuthentication</code></a>
for the <a href="../../../../core/Authentication.html" title="interface in org.springframework.security.core"><code>Authentication</code></a> and a <a href="../../../../oauth2/core/OAuth2AuthenticatedPrincipal.html" title="interface in org.springframework.security.oauth2.core"><code>OAuth2AuthenticatedPrincipal</code></a> for the
<a href="../../../../core/Authentication.html#getPrincipal()"><code>Authentication.getPrincipal()</code></a>.</div>
</td>
</tr>
<tr id="i12" class="altColor">
<td class="colFirst"><code>static org.springframework.test.web.servlet.request.RequestPostProcessor</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.html#securityContext(org.springframework.security.core.context.SecurityContext)">securityContext</a></span>&#8203;(<a href="../../../../core/context/SecurityContext.html" title="interface in org.springframework.security.core.context">SecurityContext</a>&nbsp;securityContext)</code></th>
<td class="colLast">
<div class="block">Establish the specified <a href="../../../../core/context/SecurityContext.html" title="interface in org.springframework.security.core.context"><code>SecurityContext</code></a> to be used.</div>
</td>
</tr>
<tr id="i13" class="rowColor">
<td class="colFirst"><code>static org.springframework.test.web.servlet.request.RequestPostProcessor</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.html#testSecurityContext()">testSecurityContext</a></span>()</code></th>
<td class="colLast">
<div class="block">Creates a <code>RequestPostProcessor</code> that can be used to ensure that the
resulting request is ran with the user in the <a href="../../../context/TestSecurityContextHolder.html" title="class in org.springframework.security.test.context"><code>TestSecurityContextHolder</code></a>.</div>
</td>
</tr>
<tr id="i14" class="altColor">
<td class="colFirst"><code>static <a href="SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.html#user(java.lang.String)">user</a></span>&#8203;(java.lang.String&nbsp;username)</code></th>
<td class="colLast">
<div class="block">Establish a <a href="../../../../core/context/SecurityContext.html" title="interface in org.springframework.security.core.context"><code>SecurityContext</code></a> that has a
<a href="../../../../authentication/UsernamePasswordAuthenticationToken.html" title="class in org.springframework.security.authentication"><code>UsernamePasswordAuthenticationToken</code></a> for the
<a href="../../../../core/Authentication.html#getPrincipal()"><code>Authentication.getPrincipal()</code></a> and a <a href="../../../../core/userdetails/User.html" title="class in org.springframework.security.core.userdetails"><code>User</code></a> for the
<a href="../../../../authentication/UsernamePasswordAuthenticationToken.html#getPrincipal()"><code>UsernamePasswordAuthenticationToken.getPrincipal()</code></a>.</div>
</td>
</tr>
<tr id="i15" class="rowColor">
<td class="colFirst"><code>static org.springframework.test.web.servlet.request.RequestPostProcessor</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.html#user(org.springframework.security.core.userdetails.UserDetails)">user</a></span>&#8203;(<a href="../../../../core/userdetails/UserDetails.html" title="interface in org.springframework.security.core.userdetails">UserDetails</a>&nbsp;user)</code></th>
<td class="colLast">
<div class="block">Establish a <a href="../../../../core/context/SecurityContext.html" title="interface in org.springframework.security.core.context"><code>SecurityContext</code></a> that has a
<a href="../../../../authentication/UsernamePasswordAuthenticationToken.html" title="class in org.springframework.security.authentication"><code>UsernamePasswordAuthenticationToken</code></a> for the
<a href="../../../../core/Authentication.html#getPrincipal()"><code>Authentication.getPrincipal()</code></a> and a custom <a href="../../../../core/userdetails/UserDetails.html" title="interface in org.springframework.security.core.userdetails"><code>UserDetails</code></a> for the
<a href="../../../../authentication/UsernamePasswordAuthenticationToken.html#getPrincipal()"><code>UsernamePasswordAuthenticationToken.getPrincipal()</code></a>.</div>
</td>
</tr>
<tr id="i16" class="altColor">
<td class="colFirst"><code>static org.springframework.test.web.servlet.request.RequestPostProcessor</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.html#x509(java.lang.String)">x509</a></span>&#8203;(java.lang.String&nbsp;resourceName)</code></th>
<td class="colLast">
<div class="block">Finds an X509Cetificate using a resoureName and populates it on the request.</div>
</td>
</tr>
<tr id="i17" class="rowColor">
<td class="colFirst"><code>static org.springframework.test.web.servlet.request.RequestPostProcessor</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="SecurityMockMvcRequestPostProcessors.html#x509(java.security.cert.X509Certificate...)">x509</a></span>&#8203;(java.security.cert.X509Certificate...&nbsp;certificates)</code></th>
<td class="colLast">
<div class="block">Populates the provided X509Certificate instances on the request.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a id="methods.inherited.from.class.java.lang.Object">

</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</section>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">

<section role="region">
<ul class="blockList">
<li class="blockList"><a id="method.detail">

</a>
<h3>Method Detail</h3>
<a id="digest()">

</a>
<ul class="blockList">
<li class="blockList">
<h4>digest</h4>
<pre class="methodSignature">public static&nbsp;<a href="SecurityMockMvcRequestPostProcessors.DigestRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.DigestRequestPostProcessor</a>&nbsp;digest()</pre>
<div class="block">Creates a DigestRequestPostProcessor that enables easily adding digest based
authentication to a request.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the DigestRequestPostProcessor to use</dd>
</dl>
</li>
</ul>
<a id="digest(java.lang.String)">

</a>
<ul class="blockList">
<li class="blockList">
<h4>digest</h4>
<pre class="methodSignature">public static&nbsp;<a href="SecurityMockMvcRequestPostProcessors.DigestRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.DigestRequestPostProcessor</a>&nbsp;digest&#8203;(java.lang.String&nbsp;username)</pre>
<div class="block">Creates a DigestRequestPostProcessor that enables easily adding digest based
authentication to a request.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>username</code> - the username to use</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the DigestRequestPostProcessor to use</dd>
</dl>
</li>
</ul>
<a id="x509(java.security.cert.X509Certificate...)">

</a>
<ul class="blockList">
<li class="blockList">
<h4>x509</h4>
<pre class="methodSignature">public static&nbsp;org.springframework.test.web.servlet.request.RequestPostProcessor&nbsp;x509&#8203;(java.security.cert.X509Certificate...&nbsp;certificates)</pre>
<div class="block">Populates the provided X509Certificate instances on the request.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>certificates</code> - the X509Certificate instances to pouplate</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the
<code>RequestPostProcessor</code> to use.</dd>
</dl>
</li>
</ul>
<a id="x509(java.lang.String)">

</a>
<ul class="blockList">
<li class="blockList">
<h4>x509</h4>
<pre class="methodSignature">public static&nbsp;org.springframework.test.web.servlet.request.RequestPostProcessor&nbsp;x509&#8203;(java.lang.String&nbsp;resourceName)
                                                                              throws java.io.IOException,
                                                                                     java.security.cert.CertificateException</pre>
<div class="block">Finds an X509Cetificate using a resoureName and populates it on the request.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>resourceName</code> - the name of the X509Certificate resource</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the
<code>RequestPostProcessor</code> to use.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.io.IOException</code></dd>
<dd><code>java.security.cert.CertificateException</code></dd>
</dl>
</li>
</ul>
<a id="csrf()">

</a>
<ul class="blockList">
<li class="blockList">
<h4>csrf</h4>
<pre class="methodSignature">public static&nbsp;<a href="SecurityMockMvcRequestPostProcessors.CsrfRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.CsrfRequestPostProcessor</a>&nbsp;csrf()</pre>
<div class="block">Creates a <code>RequestPostProcessor</code> that will automatically populate a valid
<a href="../../../../web/csrf/CsrfToken.html" title="interface in org.springframework.security.web.csrf"><code>CsrfToken</code></a> in the request.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the <a href="SecurityMockMvcRequestPostProcessors.CsrfRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request"><code>SecurityMockMvcRequestPostProcessors.CsrfRequestPostProcessor</code></a> for further customizations.</dd>
</dl>
</li>
</ul>
<a id="testSecurityContext()">

</a>
<ul class="blockList">
<li class="blockList">
<h4>testSecurityContext</h4>
<pre class="methodSignature">public static&nbsp;org.springframework.test.web.servlet.request.RequestPostProcessor&nbsp;testSecurityContext()</pre>
<div class="block">Creates a <code>RequestPostProcessor</code> that can be used to ensure that the
resulting request is ran with the user in the <a href="../../../context/TestSecurityContextHolder.html" title="class in org.springframework.security.test.context"><code>TestSecurityContextHolder</code></a>.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the <code>RequestPostProcessor</code> to sue</dd>
</dl>
</li>
</ul>
<a id="user(java.lang.String)">

</a>
<ul class="blockList">
<li class="blockList">
<h4>user</h4>
<pre class="methodSignature">public static&nbsp;<a href="SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor</a>&nbsp;user&#8203;(java.lang.String&nbsp;username)</pre>
<div class="block">Establish a <a href="../../../../core/context/SecurityContext.html" title="interface in org.springframework.security.core.context"><code>SecurityContext</code></a> that has a
<a href="../../../../authentication/UsernamePasswordAuthenticationToken.html" title="class in org.springframework.security.authentication"><code>UsernamePasswordAuthenticationToken</code></a> for the
<a href="../../../../core/Authentication.html#getPrincipal()"><code>Authentication.getPrincipal()</code></a> and a <a href="../../../../core/userdetails/User.html" title="class in org.springframework.security.core.userdetails"><code>User</code></a> for the
<a href="../../../../authentication/UsernamePasswordAuthenticationToken.html#getPrincipal()"><code>UsernamePasswordAuthenticationToken.getPrincipal()</code></a>. All details are
declarative and do not require that the user actually exists.
<p>
The support works by associating the user to the HttpServletRequest. To associate
the request to the SecurityContextHolder you need to ensure that the
SecurityContextPersistenceFilter is associated with the MockMvc instance. A few
ways to do this are:
</p>
<ul>
<li>Invoking apply <a href="../setup/SecurityMockMvcConfigurers.html#springSecurity()"><code>SecurityMockMvcConfigurers.springSecurity()</code></a></li>
<li>Adding Spring Security's FilterChainProxy to MockMvc</li>
<li>Manually adding <a href="../../../../web/context/SecurityContextPersistenceFilter.html" title="class in org.springframework.security.web.context"><code>SecurityContextPersistenceFilter</code></a> to the MockMvc
instance may make sense when using MockMvcBuilders standaloneSetup</li>
</ul></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>username</code> - the username to populate</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the <a href="SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request"><code>SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor</code></a> for additional customization</dd>
</dl>
</li>
</ul>
<a id="user(org.springframework.security.core.userdetails.UserDetails)">

</a>
<ul class="blockList">
<li class="blockList">
<h4>user</h4>
<pre class="methodSignature">public static&nbsp;org.springframework.test.web.servlet.request.RequestPostProcessor&nbsp;user&#8203;(<a href="../../../../core/userdetails/UserDetails.html" title="interface in org.springframework.security.core.userdetails">UserDetails</a>&nbsp;user)</pre>
<div class="block">Establish a <a href="../../../../core/context/SecurityContext.html" title="interface in org.springframework.security.core.context"><code>SecurityContext</code></a> that has a
<a href="../../../../authentication/UsernamePasswordAuthenticationToken.html" title="class in org.springframework.security.authentication"><code>UsernamePasswordAuthenticationToken</code></a> for the
<a href="../../../../core/Authentication.html#getPrincipal()"><code>Authentication.getPrincipal()</code></a> and a custom <a href="../../../../core/userdetails/UserDetails.html" title="interface in org.springframework.security.core.userdetails"><code>UserDetails</code></a> for the
<a href="../../../../authentication/UsernamePasswordAuthenticationToken.html#getPrincipal()"><code>UsernamePasswordAuthenticationToken.getPrincipal()</code></a>. All details are
declarative and do not require that the user actually exists.
<p>
The support works by associating the user to the HttpServletRequest. To associate
the request to the SecurityContextHolder you need to ensure that the
SecurityContextPersistenceFilter is associated with the MockMvc instance. A few
ways to do this are:
</p>
<ul>
<li>Invoking apply <a href="../setup/SecurityMockMvcConfigurers.html#springSecurity()"><code>SecurityMockMvcConfigurers.springSecurity()</code></a></li>
<li>Adding Spring Security's FilterChainProxy to MockMvc</li>
<li>Manually adding <a href="../../../../web/context/SecurityContextPersistenceFilter.html" title="class in org.springframework.security.web.context"><code>SecurityContextPersistenceFilter</code></a> to the MockMvc
instance may make sense when using MockMvcBuilders standaloneSetup</li>
</ul></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>user</code> - the UserDetails to populate</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the <code>RequestPostProcessor</code> to use</dd>
</dl>
</li>
</ul>
<a id="jwt()">

</a>
<ul class="blockList">
<li class="blockList">
<h4>jwt</h4>
<pre class="methodSignature">public static&nbsp;<a href="SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessor</a>&nbsp;jwt()</pre>
<div class="block">Establish a <a href="../../../../core/context/SecurityContext.html" title="interface in org.springframework.security.core.context"><code>SecurityContext</code></a> that has a <a href="../../../../oauth2/server/resource/authentication/JwtAuthenticationToken.html" title="class in org.springframework.security.oauth2.server.resource.authentication"><code>JwtAuthenticationToken</code></a> for
the <a href="../../../../core/Authentication.html" title="interface in org.springframework.security.core"><code>Authentication</code></a> and a <a href="../../../../oauth2/jwt/Jwt.html" title="class in org.springframework.security.oauth2.jwt"><code>Jwt</code></a> for the
<a href="../../../../core/Authentication.html#getPrincipal()"><code>Authentication.getPrincipal()</code></a>. All details are declarative and do not
require the JWT to be valid.
<p>
The support works by associating the authentication to the HttpServletRequest. To
associate the request to the SecurityContextHolder you need to ensure that the
SecurityContextPersistenceFilter is associated with the MockMvc instance. A few
ways to do this are:
</p>
<ul>
<li>Invoking apply <a href="../setup/SecurityMockMvcConfigurers.html#springSecurity()"><code>SecurityMockMvcConfigurers.springSecurity()</code></a></li>
<li>Adding Spring Security's FilterChainProxy to MockMvc</li>
<li>Manually adding <a href="../../../../web/context/SecurityContextPersistenceFilter.html" title="class in org.springframework.security.web.context"><code>SecurityContextPersistenceFilter</code></a> to the MockMvc
instance may make sense when using MockMvcBuilders standaloneSetup</li>
</ul></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the <a href="SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request"><code>SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessor</code></a> for additional customization</dd>
</dl>
</li>
</ul>
<a id="opaqueToken()">

</a>
<ul class="blockList">
<li class="blockList">
<h4>opaqueToken</h4>
<pre class="methodSignature">public static&nbsp;<a href="SecurityMockMvcRequestPostProcessors.OpaqueTokenRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.OpaqueTokenRequestPostProcessor</a>&nbsp;opaqueToken()</pre>
<div class="block">Establish a <a href="../../../../core/context/SecurityContext.html" title="interface in org.springframework.security.core.context"><code>SecurityContext</code></a> that has a <a href="../../../../oauth2/server/resource/authentication/BearerTokenAuthentication.html" title="class in org.springframework.security.oauth2.server.resource.authentication"><code>BearerTokenAuthentication</code></a>
for the <a href="../../../../core/Authentication.html" title="interface in org.springframework.security.core"><code>Authentication</code></a> and a <a href="../../../../oauth2/core/OAuth2AuthenticatedPrincipal.html" title="interface in org.springframework.security.oauth2.core"><code>OAuth2AuthenticatedPrincipal</code></a> for the
<a href="../../../../core/Authentication.html#getPrincipal()"><code>Authentication.getPrincipal()</code></a>. All details are declarative and do not
require the token to be valid
<p>
The support works by associating the authentication to the HttpServletRequest. To
associate the request to the SecurityContextHolder you need to ensure that the
SecurityContextPersistenceFilter is associated with the MockMvc instance. A few
ways to do this are:
</p>
<ul>
<li>Invoking apply <a href="../setup/SecurityMockMvcConfigurers.html#springSecurity()"><code>SecurityMockMvcConfigurers.springSecurity()</code></a></li>
<li>Adding Spring Security's FilterChainProxy to MockMvc</li>
<li>Manually adding <a href="../../../../web/context/SecurityContextPersistenceFilter.html" title="class in org.springframework.security.web.context"><code>SecurityContextPersistenceFilter</code></a> to the MockMvc
instance may make sense when using MockMvcBuilders standaloneSetup</li>
</ul></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the <a href="SecurityMockMvcRequestPostProcessors.OpaqueTokenRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request"><code>SecurityMockMvcRequestPostProcessors.OpaqueTokenRequestPostProcessor</code></a> for additional customization</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>5.3</dd>
</dl>
</li>
</ul>
<a id="authentication(org.springframework.security.core.Authentication)">

</a>
<ul class="blockList">
<li class="blockList">
<h4>authentication</h4>
<pre class="methodSignature">public static&nbsp;org.springframework.test.web.servlet.request.RequestPostProcessor&nbsp;authentication&#8203;(<a href="../../../../core/Authentication.html" title="interface in org.springframework.security.core">Authentication</a>&nbsp;authentication)</pre>
<div class="block">Establish a <a href="../../../../core/context/SecurityContext.html" title="interface in org.springframework.security.core.context"><code>SecurityContext</code></a> that uses the specified <a href="../../../../core/Authentication.html" title="interface in org.springframework.security.core"><code>Authentication</code></a>
for the <a href="../../../../core/Authentication.html#getPrincipal()"><code>Authentication.getPrincipal()</code></a> and a custom <a href="../../../../core/userdetails/UserDetails.html" title="interface in org.springframework.security.core.userdetails"><code>UserDetails</code></a>. All
details are declarative and do not require that the user actually exists.
<p>
The support works by associating the user to the HttpServletRequest. To associate
the request to the SecurityContextHolder you need to ensure that the
SecurityContextPersistenceFilter is associated with the MockMvc instance. A few
ways to do this are:
</p>
<ul>
<li>Invoking apply <a href="../setup/SecurityMockMvcConfigurers.html#springSecurity()"><code>SecurityMockMvcConfigurers.springSecurity()</code></a></li>
<li>Adding Spring Security's FilterChainProxy to MockMvc</li>
<li>Manually adding <a href="../../../../web/context/SecurityContextPersistenceFilter.html" title="class in org.springframework.security.web.context"><code>SecurityContextPersistenceFilter</code></a> to the MockMvc
instance may make sense when using MockMvcBuilders standaloneSetup</li>
</ul></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>authentication</code> - the Authentication to populate</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the <code>RequestPostProcessor</code> to use</dd>
</dl>
</li>
</ul>
<a id="anonymous()">

</a>
<ul class="blockList">
<li class="blockList">
<h4>anonymous</h4>
<pre class="methodSignature">public static&nbsp;org.springframework.test.web.servlet.request.RequestPostProcessor&nbsp;anonymous()</pre>
<div class="block">Establish a <a href="../../../../core/context/SecurityContext.html" title="interface in org.springframework.security.core.context"><code>SecurityContext</code></a> that uses an
<a href="../../../../authentication/AnonymousAuthenticationToken.html" title="class in org.springframework.security.authentication"><code>AnonymousAuthenticationToken</code></a>. This is useful when a user wants to run a
majority of tests as a specific user and wishes to override a few methods to be
anonymous. For example:
<pre> <code>
 public class SecurityTests {
     &#064;Before
     public void setup() {
         mockMvc = MockMvcBuilders
             .webAppContextSetup(context)
             .defaultRequest(get("/").with(user("user")))
             .build();
     }

     &#064;Test
     public void anonymous() {
         mockMvc.perform(get("anonymous").with(anonymous()));
     }
     // ... lots of tests ran with a default user ...
 }
 </code> </pre></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the <code>RequestPostProcessor</code> to use</dd>
</dl>
</li>
</ul>
<a id="securityContext(org.springframework.security.core.context.SecurityContext)">

</a>
<ul class="blockList">
<li class="blockList">
<h4>securityContext</h4>
<pre class="methodSignature">public static&nbsp;org.springframework.test.web.servlet.request.RequestPostProcessor&nbsp;securityContext&#8203;(<a href="../../../../core/context/SecurityContext.html" title="interface in org.springframework.security.core.context">SecurityContext</a>&nbsp;securityContext)</pre>
<div class="block">Establish the specified <a href="../../../../core/context/SecurityContext.html" title="interface in org.springframework.security.core.context"><code>SecurityContext</code></a> to be used.
<p>
This works by associating the user to the <code>HttpServletRequest</code>. To associate
the request to the <a href="../../../../core/context/SecurityContextHolder.html" title="class in org.springframework.security.core.context"><code>SecurityContextHolder</code></a> you need to ensure that the
<a href="../../../../web/context/SecurityContextPersistenceFilter.html" title="class in org.springframework.security.web.context"><code>SecurityContextPersistenceFilter</code></a> (i.e. Spring Security's FilterChainProxy
will typically do this) is associated with the <code>MockMvc</code> instance.
</p></div>
</li>
</ul>
<a id="httpBasic(java.lang.String,java.lang.String)">

</a>
<ul class="blockList">
<li class="blockList">
<h4>httpBasic</h4>
<pre class="methodSignature">public static&nbsp;org.springframework.test.web.servlet.request.RequestPostProcessor&nbsp;httpBasic&#8203;(java.lang.String&nbsp;username,
                                                                                          java.lang.String&nbsp;password)</pre>
<div class="block">Convenience mechanism for setting the Authorization header to use HTTP Basic with
the given username and password. This method will automatically perform the
necessary Base64 encoding.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>username</code> - the username to include in the Authorization header.</dd>
<dd><code>password</code> - the password to include in the Authorization header.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the <code>RequestPostProcessor</code> to use</dd>
</dl>
</li>
</ul>
<a id="oauth2Login()">

</a>
<ul class="blockList">
<li class="blockList">
<h4>oauth2Login</h4>
<pre class="methodSignature">public static&nbsp;<a href="SecurityMockMvcRequestPostProcessors.OAuth2LoginRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.OAuth2LoginRequestPostProcessor</a>&nbsp;oauth2Login()</pre>
<div class="block">Establish a <a href="../../../../core/context/SecurityContext.html" title="interface in org.springframework.security.core.context"><code>SecurityContext</code></a> that has a <a href="../../../../oauth2/client/authentication/OAuth2AuthenticationToken.html" title="class in org.springframework.security.oauth2.client.authentication"><code>OAuth2AuthenticationToken</code></a>
for the <a href="../../../../core/Authentication.html" title="interface in org.springframework.security.core"><code>Authentication</code></a>, a <a href="../../../../oauth2/core/user/OAuth2User.html" title="interface in org.springframework.security.oauth2.core.user"><code>OAuth2User</code></a> as the principal, and a
<a href="../../../../oauth2/client/OAuth2AuthorizedClient.html" title="class in org.springframework.security.oauth2.client"><code>OAuth2AuthorizedClient</code></a> in the session. All details are declarative and do
not require associated tokens to be valid.
<p>
The support works by associating the authentication to the HttpServletRequest. To
associate the request to the SecurityContextHolder you need to ensure that the
SecurityContextPersistenceFilter is associated with the MockMvc instance. A few
ways to do this are:
</p>
<ul>
<li>Invoking apply <a href="../setup/SecurityMockMvcConfigurers.html#springSecurity()"><code>SecurityMockMvcConfigurers.springSecurity()</code></a></li>
<li>Adding Spring Security's FilterChainProxy to MockMvc</li>
<li>Manually adding <a href="../../../../web/context/SecurityContextPersistenceFilter.html" title="class in org.springframework.security.web.context"><code>SecurityContextPersistenceFilter</code></a> to the MockMvc
instance may make sense when using MockMvcBuilders standaloneSetup</li>
</ul></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the <a href="SecurityMockMvcRequestPostProcessors.OidcLoginRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request"><code>SecurityMockMvcRequestPostProcessors.OidcLoginRequestPostProcessor</code></a> for additional customization</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>5.3</dd>
</dl>
</li>
</ul>
<a id="oidcLogin()">

</a>
<ul class="blockList">
<li class="blockList">
<h4>oidcLogin</h4>
<pre class="methodSignature">public static&nbsp;<a href="SecurityMockMvcRequestPostProcessors.OidcLoginRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.OidcLoginRequestPostProcessor</a>&nbsp;oidcLogin()</pre>
<div class="block">Establish a <a href="../../../../core/context/SecurityContext.html" title="interface in org.springframework.security.core.context"><code>SecurityContext</code></a> that has a <a href="../../../../oauth2/client/authentication/OAuth2AuthenticationToken.html" title="class in org.springframework.security.oauth2.client.authentication"><code>OAuth2AuthenticationToken</code></a>
for the <a href="../../../../core/Authentication.html" title="interface in org.springframework.security.core"><code>Authentication</code></a>, a <a href="../../../../oauth2/core/oidc/user/OidcUser.html" title="interface in org.springframework.security.oauth2.core.oidc.user"><code>OidcUser</code></a> as the principal, and a
<a href="../../../../oauth2/client/OAuth2AuthorizedClient.html" title="class in org.springframework.security.oauth2.client"><code>OAuth2AuthorizedClient</code></a> in the session. All details are declarative and do
not require associated tokens to be valid.
<p>
The support works by associating the authentication to the HttpServletRequest. To
associate the request to the SecurityContextHolder you need to ensure that the
SecurityContextPersistenceFilter is associated with the MockMvc instance. A few
ways to do this are:
</p>
<ul>
<li>Invoking apply <a href="../setup/SecurityMockMvcConfigurers.html#springSecurity()"><code>SecurityMockMvcConfigurers.springSecurity()</code></a></li>
<li>Adding Spring Security's FilterChainProxy to MockMvc</li>
<li>Manually adding <a href="../../../../web/context/SecurityContextPersistenceFilter.html" title="class in org.springframework.security.web.context"><code>SecurityContextPersistenceFilter</code></a> to the MockMvc
instance may make sense when using MockMvcBuilders standaloneSetup</li>
</ul></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the <a href="SecurityMockMvcRequestPostProcessors.OidcLoginRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request"><code>SecurityMockMvcRequestPostProcessors.OidcLoginRequestPostProcessor</code></a> for additional customization</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>5.3</dd>
</dl>
</li>
</ul>
<a id="oauth2Client()">

</a>
<ul class="blockList">
<li class="blockList">
<h4>oauth2Client</h4>
<pre class="methodSignature">public static&nbsp;<a href="SecurityMockMvcRequestPostProcessors.OAuth2ClientRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.OAuth2ClientRequestPostProcessor</a>&nbsp;oauth2Client()</pre>
<div class="block">Establish an <a href="../../../../oauth2/client/OAuth2AuthorizedClient.html" title="class in org.springframework.security.oauth2.client"><code>OAuth2AuthorizedClient</code></a> in the session. All details are
declarative and do not require associated tokens to be valid.
<p>
The support works by associating the authorized client to the HttpServletRequest
via the <a href="../../../../oauth2/client/web/HttpSessionOAuth2AuthorizedClientRepository.html" title="class in org.springframework.security.oauth2.client.web"><code>HttpSessionOAuth2AuthorizedClientRepository</code></a>
</p></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the <a href="SecurityMockMvcRequestPostProcessors.OAuth2ClientRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request"><code>SecurityMockMvcRequestPostProcessors.OAuth2ClientRequestPostProcessor</code></a> for additional customization</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>5.3</dd>
</dl>
</li>
</ul>
<a id="oauth2Client(java.lang.String)">

</a>
<ul class="blockListLast">
<li class="blockList">
<h4>oauth2Client</h4>
<pre class="methodSignature">public static&nbsp;<a href="SecurityMockMvcRequestPostProcessors.OAuth2ClientRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request">SecurityMockMvcRequestPostProcessors.OAuth2ClientRequestPostProcessor</a>&nbsp;oauth2Client&#8203;(java.lang.String&nbsp;registrationId)</pre>
<div class="block">Establish an <a href="../../../../oauth2/client/OAuth2AuthorizedClient.html" title="class in org.springframework.security.oauth2.client"><code>OAuth2AuthorizedClient</code></a> in the session. All details are
declarative and do not require associated tokens to be valid.
<p>
The support works by associating the authorized client to the HttpServletRequest
via the <a href="../../../../oauth2/client/web/HttpSessionOAuth2AuthorizedClientRepository.html" title="class in org.springframework.security.oauth2.client.web"><code>HttpSessionOAuth2AuthorizedClientRepository</code></a>
</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>registrationId</code> - The registration id for the <a href="../../../../oauth2/client/OAuth2AuthorizedClient.html" title="class in org.springframework.security.oauth2.client"><code>OAuth2AuthorizedClient</code></a></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the <a href="SecurityMockMvcRequestPostProcessors.OAuth2ClientRequestPostProcessor.html" title="class in org.springframework.security.test.web.servlet.request"><code>SecurityMockMvcRequestPostProcessors.OAuth2ClientRequestPostProcessor</code></a> for additional customization</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>5.3</dd>
</dl>
</li>
</ul>
</li>
</ul>
</section>
</li>
</ul>
</div>
</div>
</main>

<footer role="contentinfo">
<nav role="navigation">

<div class="bottomNav"><a id="navbar.bottom">

</a>
<div class="skipNav"><a href="SecurityMockMvcRequestPostProcessors.html#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.bottom.firstrow">

</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../../index.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../../../allclasses.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_bottom");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li><a href="SecurityMockMvcRequestPostProcessors.html#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="SecurityMockMvcRequestPostProcessors.html#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="SecurityMockMvcRequestPostProcessors.html#method.detail">Method</a></li>
</ul>
</div>
<a id="skip.navbar.bottom">

</a></div>

</nav>
</footer>
<script>if (window.parent == window) {(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-2728886-23', 'auto', {'siteSpeedSampleRate': 100});ga('send', 'pageview');}</script><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v652eace1692a40cfa3763df669d7439c1639079717194" integrity="sha512-Gi7xpJR8tSkrpF7aordPZQlW2DLtzUlZcumS8dMQjwDHEnw9I7ZLyiOj/6tZStRBGtGgN6ceN6cMH8z7etPGlw==" data-cf-beacon='{"rayId":"7040ee2dff9797cf","token":"bffcb8a918ae4755926f76178bfbd26b","version":"2021.12.0","si":100}' crossorigin="anonymous"></script>
</body>
</html>
